Fix Proxmox/LXC memory conversion Lxc.pm #869
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue:
The glpi-agent was incorrectly handling memory values for LXC containers on hosts using Proxmox.
Proxmox returns a raw byte value (e.g., "10737418240") without a unit suffix, and the current logic
in getCanonicalSize() immediately returns such plain numeric values. This leads to storing the
value in bytes instead of the expected megabytes (MB), potentially causing an overflow in an
unsigned int database column.
Solution:
so that getCanonicalSize() processes them correctly.
the value from bytes to MB by dividing by (1024 * 1024).
Changes:
elsif
branch to check if the memory value is a plain number using/^\d+$/
.int($val / (1024 * 1024))